package com.xmlt.core.template.expression;

import java.util.Collections;
import java.util.Enumeration;

import com.xmlt.core.template.instance.MultiInstance;


import ognl.ElementsAccessor;
import ognl.OgnlException;

public class InstanceElementsAccessor implements ElementsAccessor {

	@Override
	public Enumeration<?> getElements(Object target) throws OgnlException {
		if (!(target instanceof MultiInstance))
			throw new OgnlException("This accessor is only valid for multi-instances.");
		MultiInstance mi = (MultiInstance) target;
		return Collections.enumeration(mi.getChildren());
	}

}
